$.extend(true, $.fn.raty.defaults, {
    path: "/images/stars",
    size: 16,
    half: false, //是否有半星
    hints: ["一星", "两星", "三星", "四星", "五星"],
    mouseover: function (score) {
        if (!this.readOnly) {
            creatTipDiv(this.id);
            document.getElementById(this.id + "_starTip").innerHTML = getStartTitle(score);
        }
    },
    mouseout: function (score) {
        if (!this.readOnly) {
            creatTipDiv(this.id);
            var getScore = parseFloat($(this).children("input").val());
            document.getElementById(this.id + "_starTip").innerHTML = getStartTitle(getScore);
        }
    },
    click: function (score, evt) {
        if (!this.readOnly) {
            creatTipDiv(this.id);
            $(this).children("input").val(score);
            document.getElementById(this.id + "_starTip").innerHTML = getStartTitle(score);
        }
    }
});

function creatTipDiv(starContainerId) {
    var starContainer = $("#" + starContainerId);
    if (starContainer.length > 0 && $("#" + starContainerId + "_starTip").length < 1) {
        starContainer.after("<div id='" + starContainerId + "_starTip' class='star-tip'></div>");
    }
}


function getStartTitle(startAlt) {
    var str = "";
    switch (startAlt) {
        case 0.5:
            str = "一星";
        case 1:
            str = "一星";
            break;
        case 1.5:
            str = "两星";
            break;
        case 2:
            str = "两星";
            break;
        case 2.5:
            str = "三星";
            break;
        case 3:
            str = "三星";
            break;
        case 3.5:
            str = "四星";
            break;
        case 4:
            str = "四星";
            break;
        case 4.5:
            str = "五星";
            break;
        case 5:
            str = "五星";
            break;
        default:
            str = "未评分";
            break;
    }
    return str;
}

